package com.testfileupload.uploadimg.design.prototype;

import java.util.Random;

public class Client {
    //发送账单数量，从数据库获取
    public static int Max_Count = 6;

    public static void main(String[] args) throws CloneNotSupportedException {
        //模拟发送邮件
        int i = 0;
        ShelldowMail shelldowMail = new ShelldowMail(new AVTemplate());
        shelldowMail.setTail("xx银行版权所有");
        while (i < Max_Count) {
            ShelldowMail cloneShelldowMail = (ShelldowMail) shelldowMail.clone();
            cloneShelldowMail.setAppellation(getRandString(5) + "先生(女士)");
            cloneShelldowMail.setReceiver(getRandString(5) + "@" + getRandString(8) + ".com");
            sendMail(cloneShelldowMail);
            i++;
        }
    }

    private static void sendMail(ShelldowMail shelldowMail) {
        System.out.println("标题" + shelldowMail.getAppellation() + " 收件人邮箱"
                + shelldowMail.getReceiver());
    }

    private static String getRandString(int maxLength) {
        String source = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
        StringBuffer stringBuffer = new StringBuffer();
        Random random = new Random();
        for (int i = 0; i < maxLength; i++) {
            stringBuffer.append(source.charAt(random.nextInt(source.length())));
        }
        return stringBuffer.toString();

    }
}
